package kuzmenkov.oip.controller.applet;

import java.util.logging.Logger;

import javax.swing.JPanel;


/**
 * Class is generic for all GUI param component
 * @author Michael Kuzmenkov
 *
 */
public abstract class ParamUIC extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 2880507581423970555L;
	private static final Logger log = Logger.getLogger(ParamUIC.class.getName());
	private Param param;
	protected static final int MAX_TIP_LENGTH = 100; 
	
	protected ParamUIC(Param param) {
		this.param = param;
	}
	
	protected Param getParam () {
		return param;
	}
	
	/** 
	 * @return the user entry value
	 */
	public abstract Object getValue();


	public abstract void setValue(Object object) ;

    protected String truncateString(String str, int maxLength) {
    	if (str == null){
    		return null;
    	}
        if (maxLength < 1) {
            log.warning("Illegal parameters: maxLength=" + maxLength);
            return null;
        }
        if (str.length() > maxLength) {
            str = str.substring(0, maxLength).trim() + "...";
        }

        return str;
    }

}
